import urllib.request as ur
import user_agent


procy_handler = ur.ProxyHandler(
    {
        'http': '123.59.195.170'
    }
)

procy_opener = ur.build_opener(procy_handler)

request = ur.Request(
    url='https://edu.csdn.net/',
    headers={
        'User-Agent': user_agent.get_user_agent_pc(),
        'Cookie': '2760823115711433602705780e725725395657e75df5b8cd6c6bbef98fe835; uuid_tt_dd=10_19289830350-1571143360784-741305; dc_session_id=10_1571143360784.456860; acw_sc__v2=5da5bec036444cdf8c364f3514c54b69c7c253c8; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1571143363; Hm_ct_6bcd52f51e9b3dce32bec4a3997715ac=6525*1*10_19289830350-1571143360784-741305; firstDie=1; dc_tos=pzf2yj; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1571144636; c-login-auto=4',
    }
)
response = ur.urlopen(request).read().decode('utf-8')
print(response)
with open('procy_demo.html', 'w', encoding='utf-8') as f:
    f.write(response)